Ext.define('Zm.view.line.Edit',{
    extend:'Ext.window.Window',
    alias:'widget.lineedit',
    uses:['Ext.form.Panel',
        'Ext.ux.TreePicker',
        'Zm.store.PortTree',
        'Zm.i18n.Lang'
    ],
    layout:'fit',
    autoShow:true,
    width:400,
    modal:true,
    
    initComponent: function(){
        var me = this,
            lang = Zm.i18n.Lang;
        me.srcPort = Ext.create('Zm.store.PortTree',{autoLoad:true});
        me.destPort = Ext.create('Zm.store.PortTree',{autoLoad:true});
        Ext.apply(me,{
            title:lang.tLineEdit,
            items:[{
                xtype:'form',
                bodyStyle:'padding:5px 5px 0',
                fieldDefaults:{
                    labelAlign:'right',
                    labelWidth: 120,
                    anchor:'99%'
                },
                items:[{
                    xtype:'treepicker',
                    name:'sdevid',
                    fieldLabel:lang.tDev1,
                    store:me.srcPort,
                    rootVisible:false,
                    displayField:'text',
                    listeners:{
                        select:{
                            fn:me.onDevSel,
                            scope:me
                        }  
                    },
                    allowBlank:false
                },{
                    xtype:'treepicker',
                    name:'devid',
                    fieldLabel:lang.tDev2,
                    store:me.destPort,
                    rootVisible:false,
                    displayField:'text',
                    allowBlank:false
                }],
                buttonAlign:'center',
                buttons:[{
                    text:lang.tSave,
                    formBind:true,
                    action:'save'
                },{
                    text:lang.tCancel,
                    handler: function(){
                        me.close();
                    }
                }]
            }]
        });
        me.callParent(arguments);
    },
    onDevSel:function(picker,record,eOpts){
        var me = this,
            devid = record.get('id'),
            store = me.destPort,
            proxy = store.getProxy();
        proxy.extraParams = {devid:devid};
        store.load();
    }
});